package com.pkk.spring.cloud.web.runner.controller.kafka.config;

import org.apache.kafka.clients.admin.NewTopic;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.core.ProducerFactory;
import org.springframework.kafka.transaction.KafkaTransactionManager;

import java.util.Map;

import static com.pkk.spring.cloud.web.runner.controller.kafka.constant.KafkaConstant.OTHER_SIMPLE_TOPIC;
import static com.pkk.spring.cloud.web.runner.controller.kafka.constant.KafkaConstant.SIMPLE_TOPIC;

/**
 * @description: kafka的初始化创建配置
 * @author: peikunkun
 * @create: 2021-05-24 16:11
 **/
@Configuration
public class KafkaInitConfiguration {


    /**
     * 初始化一个简单的topic,分区为6个，副本为2个，当做修改的时候，分区数量只能增加，不能减少，重启项目生效，分区数据不变
     *
     * @return org.apache.kafka.clients.admin.NewTopic
     * @author peikunkun
     * @date 2021/5/24 16:45
     */
    @Bean
    public NewTopic initSimpleKafkaTopic() {
        return new NewTopic(SIMPLE_TOPIC, 6, (short) 2);
    }


    @Bean
    public NewTopic initOtherSimpleKafkaTopic() {
        return new NewTopic(OTHER_SIMPLE_TOPIC, 4, (short) 1);
    }


}
